使用文字描述與流程圖表達


題目:判斷年紀是否滿足投票標準(假設 20 歲(含)以上可以投票)。


*文字描述

1.用戶輸入年齡 = input('請輸入年齡')
2.判斷input值:
-用戶年齡大於等於20歲,則print('可以投票')
-用戶年齡小於20歲,則print('不具投票權')
3.End program


*流程圖表達


*邏輯轉換為程式碼

"""
程式碼註解:
input() 顯示你設定的內容讓使用者看到,並讓使用者能夠填寫互動。eg:請輸入你的年紀。
int() 把文字字串轉為數值「整數」。
age 變數,命名input中輸入的內容,可以想成變數是用來暫存了一些資料方便之後程式使用。
"""
raw_data = input('請輸入你的年齡')
age = int(raw_data)
if age>=20:
    print('符合投票資格')
else:
    print('不符合投票資格')
#Python






你可能感興趣的文章

資結、Introduction to Algorithm Design

資結、Introduction to Algorithm Design

Vue.js 學習旅程Mile 9 – Event Handling 事件處理篇-1:methods & v-on

Vue.js 學習旅程Mile 9 – Event Handling 事件處理篇-1:methods & v-on

【隨堂筆記】運算思維與流程圖

【隨堂筆記】運算思維與流程圖






留言討論